#ifndef NUMERICKEYBOARD_H
#define NUMERICKEYBOARD_H

#include <QWidget>
#include <QLineEdit>

class QPushButton;
class QGridLayout;

class NumericKeyboard : public QWidget
{
    Q_OBJECT

public:
    explicit NumericKeyboard(QWidget *parent = nullptr);

    void setTargetLineEdit(QLineEdit *lineEdit);
    void showAtPosition(const QPoint &pos);

signals:
    void keyPressed(const QString &key);

private slots:
    void onDigitButtonClicked();
    void onBackspaceClicked();
    void onClearClicked();

private:
    QLineEdit *targetLineEdit;
    QPushButton *createButton(const QString &text, const char *member);

    // 按钮指针
    QPushButton *digitButtons[10];
    QPushButton *backspaceButton;
    QPushButton *clearButton;
    QPushButton *closeButton;
};

#endif // NUMERICKEYBOARD_H
